import request from '../utils/request'

const url = "/admin/module"

/**
 * 添加
 * @param data
 * @returns {AxiosPromise}
 */
export const add = (data) => {
  return request({
    url: url + "/add",
    method: 'post',
    data
  })
}

/**
 * 逻辑删除
 * @param id
 * @returns {AxiosPromise}
 */
export const deleteOne = (id) => {
  return request({
    url: url + '/' + id,
    method: 'delete',
  })
}

/**
 * 批量删除
 * @param ids
 * @returns {*}
 */
export const deleteBatch = (ids) => {
  return request({
    url: url + '/batch/' + ids,
    method: 'delete',
  })
}

/**
 * 编辑
 * @param data
 * @returns {*}
 */
export const edit = (data) => {
  return request({
    url: url,
    method: 'put',
    data
  })
}

/**
 * 分页查询
 * @param params
 * @param data
 * @returns {*}
 */
export const getList = (params, data) => {
  return request({
    url: url + '/page',
    method: 'post',
    params,
    data
  })
}

/**
 * 查询通用模板
 * @param params
 * @param data
 * @returns {*}
 */
export const getCommonList = (params) => {
  return request({
    url: url + '/getCommonList',
    method: 'get',
    params
  })
}

/**
 * 根据通用模板生成代码
 * @param params
 * @param data
 * @returns {*}
 */
export const createCommonModule = (params) => {
  return request({
    url: url + '/createCommonModule',
    method: 'get',
    params
  })
}


